<template>
	<view class="box">
		<view style="padding-top: 40vh;" v-if="!resObj.troubleId">
			<u-empty mode="list"></u-empty>
		</view>
		<view :class="!actionBar ?'plr20 ptb20':'plr20 pt20 pb240'" v-if="resObj.troubleId">
			<view class="boxItem mb20">
				<view class="tc mb30">基本信息</view>
				<view class="flex mb20">
					<view class="name w160">隐患简题：</view>
					<view class="value">{{resObj.troubleTitle}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患编号：</view>
					<view class="value">{{resObj.troubleNum}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患所在单位：</view>
					<view class="value">{{resObj.troubleUnit}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患类型：</view>
					<view class="value">{{resObj.specialtyAssort}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患来源：</view>
					<view class="value">{{resObj.troubleSource}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">填报人：</view>
					<view class="value">{{resObj.createUser}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">填报人所属单位：</view>
					<view class="value">{{resObj.createOrg}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">发现人：</view>
					<view class="value">{{resObj.findPeople}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">发现人所属单位：</view>
					<view class="value">{{resObj.findPeopleUnit}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">填报时间：</view>
					<view class="value">{{resObj.createDate | spliceDate}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">发现日期：</view>
					<view class="value">{{resObj.findDate | spliceDate}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患内容：</view>
					<view class="value">{{resObj.troubleContent}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">归属职能部门：</view>
					<view class="value">{{resObj.attachFunctDept}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">相关附件：</view>
					<view class="cob" @click="checkAttac('080106')">查看</view>
				</view>
			</view>


			<!-- <view class="boxItem mb20">
				<view class="tc mb30">预评估信息</view>
				<view class="flex mb20">
					<view class="name w160">预评估等级：</view>
					<view class="value">{{resObj.priorEvaGrade}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">预评估负责人：</view>
					<view class="value">{{resObj.priorEvaPeople}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">预评估时间：</view>
					<view class="value">{{resObj.priorEvaDate}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">预评估审核领导：</view>
					<view class="value">{{resObj.priorEvaLeader}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">预评估审核时间：</view>
					<view class="value">{{resObj.priorEvaLeaderDate}}</view>
				</view>
			</view> -->


			<view class="boxItem mb20">
				<view class="tc mb30">评估信息</view>
				<view class="flex mb20">
					<view class="name w160">评估等级：</view>
					<view class="value">{{resObj.evaGrade}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">评估负责人：</view>
					<view class="value">{{resObj.evaPeople}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">评估时间：</view>
					<view class="value">{{resObj.evaPeopleDate | spliceDate}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">评估审核领导：</view>
					<view class="value">{{resObj.evaCoLeader}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">评估审核时间：</view>
					<view class="value">{{resObj.evaCoLeaderDate | spliceDate}}</view>
				</view>
			</view>
			<view class="boxItem mb20">
				<view class="tc mb30">核定信息</view>
				<view class="flex mb20">
					<view class="name w160">职能部门负责人：</view>
					<view class="value">{{resObj.functDeptPeople}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">部门负责人签字日期：</view>
					<view class="value">{{resObj.functDeptPeopleDate | spliceDate}}</view>
				</view>
			</view>
			<view class="boxItem mb20">
				<view class="tc mb30">治理信息</view>
				<view class="flex mb20">
					<view class="name w160">治理责任单位：</view>
					<view class="value">{{resObj.rnvUnit}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">治理责任人：</view>
					<view class="value">{{resObj.rnvPeople}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">治理期限起始日期：</view>
					<view class="value">{{resObj.rnvStartDate | spliceDate}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">治理期限终止日期：</view>
					<view class="value">{{resObj.rnvEndDate | spliceDate}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">计划项目：</view>
					<view class="value">{{resObj.isProject==1?'是':'否'}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">治理措施/方案：</view>
					<view class="value">{{resObj.treatmentPlan}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">治理措施/方案附件：</view>
					<view class="cob" @click="checkAttac('080105')">查看</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">整改完成前防护措施：</view>
					<view class="value">{{resObj.rnvMeasure}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">防控措施附件：</view>
					<view class="cob" @click="checkAttac('080104')">查看</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">治理(整改)完成情况：</view>
					<view class="value">{{resObj.rnvEndCircs}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">治理完成情况附件：</view>
					<view class="cob" @click="checkAttac('080102')">查看</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">治理计划资金(万元)：</view>
					<view class="value">{{resObj.planMoney}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">累计投入资金(万元)：</view>
					<view class="value">{{resObj.toteBankroll}}</view>
				</view>
			</view>

			<view class="boxItem mb20">
				<view class="tc mb30">验收信息</view>
				<view class="flex mb20">
					<view class="name w160">验收申请单位：</view>
					<view class="value">{{resObj.caApplyUnit}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">验收责任人：</view>
					<view class="value">{{resObj.caPeople}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">签字日期：</view>
					<view class="value">{{resObj.caPeopleDate| spliceDate}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">验收组织单位：</view>
					<view class="value">{{resObj.caOrganizeUnit}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">验收意见：</view>
					<view class="value">{{resObj.caOpinion}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">验收意见附件：</view>
					<view class="cob" @click="checkAttac('080103')">查看</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">验收结论：</view>
					<view class="value">{{resObj.caVerdict}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">是否消除隐患：</view>
					<view class="value">{{resObj.isRemoveTrouble==1?'是':'否'}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">验收组长：</view>
					<view class="value">{{resObj.caGroup}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">签字日期：</view>
					<view class="value">{{resObj.caGroupDate | spliceDate}}</view>
				</view>
			</view>
		</view>
		<view class="maintenance" v-if="actionBar">
			<view>
				<image src="../../static/iconAuditInformation.png" @click="navTo('auditOpinion')"></image>
				<view>审核信息</view>
			</view>
			<view>
				<image src="../../static/iconTransferInformation.png" @click="navTo('transferInformation')"></image>
				<view>流转信息</view>
			</view>
			<view v-if="flag!=2">
				<image src="../../static/iconSendBack.png" @click="show=true"></image>
				<view>撤回</view>
			</view>
		</view>
		<u-popup :show="show" mode="center" @close="show=false">
			<view class="popup">
				<view class="mb50">确定撤回该隐患信息吗？</view>
				<view class="flex flex-two">
					<view class="btn but1" @click="show=false">取消</view>
					<view class="btn but2" @click="recall">确定</view>
				</view>
			</view>
		</u-popup>
	</view>

	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				flag:0,
				//底部操作栏
				actionBar: false,
				//撤回弹窗
				// show:false,
				//隐患对象
				resObj: {},
				//所有字典列表
				dictList: [],
				params: {},
				show: false
			}
		},
		onLoad(e) {
			if(e.flag){
				this.actionBar = true
				this.flag = e.flag
			}
			if (e.hiddenDangerId) {
				let lampArr = e.hiddenDangerId
				this.params.troubleId = e.hiddenDangerId
				console.log(lampArr)
				this.request(this.$api.selectDataById, this.params, "POST").then((res) => {
					console.log(123, res.resultValue)
					this.resObj = res.resultValue.items[0]
					this.dictList = res.resultValue.dicts
					this.dictsFn()
				})
			}
		},
		filters:{
			spliceDate(e){
				return e == null ? '' : (e+'').slice(0,11)
			}
		},
		methods: {
			//撤回
			async recall() {
				let res = await this.request(this.$api.revokeHiddeninfo, this.params, "POST")
				uni.showToast({
					title: '撤回',
					icon: 'success'
				})
				setTimeout(() => {
					var pages = getCurrentPages(); // 当前页面
					var beforePage = pages[pages.length - 2]; // 前一个页面
					uni.navigateBack({
						success: function() {
							beforePage.$vm.init(); // 执行前一个页面的方法
						}
					})
				}, 1000)
			},
			dictsFn() {
				let obj = {
					specialtyAssort: this.resObj.specialtyAssort,
					troubleSource: this.resObj.troubleSource,
					attachFunctDept: this.resObj.attachFunctDept,
					priorEvaGrade: this.resObj.priorEvaGrade,
					evaGrade: this.resObj.evaGrade
				}
				let arr = []
				for (let k in obj) {
					this.dictList.forEach(item => {
						if (k == item.name) {
							item.values.forEach(i => {
								if (obj[k] == i.value) {
									arr.push({
										name: k,
										value: i.text
									})
								}
							})
						}
					})
				}
				console.log(this.dictList, 123456)
				arr.forEach((item) => {
					if (item.name == "specialtyAssort") {
						this.resObj.specialtyAssort = item.value
					} else if (item.name == "troubleSource") {
						this.resObj.troubleSource = item.value
					} else if (item.name == "attachFunctDept") {
						this.resObj.attachFunctDept = item.value
					} else if (item.name == "priorEvaGrade") {
						this.resObj.priorEvaGrade = item.value
					} else if (item.name == "evaGrade") {
						this.resObj.evaGrade = item.value
					}
				})
			},
			//页面跳转
			navTo(e) {
				uni.navigateTo({
					url: './' + e + '?item=' + JSON.stringify(this.resObj) + '&dictList=' + JSON.stringify(this
						.dictList)
				})
			},
			checkAttac(classify) {
				console.log(classify + '\n' + this.resObj.troubleId)
				uni.navigateTo({
					url: './../checkTheAttachment/checkTheAttachment?classify=' + classify + '&connectId=' + this
						.resObj.troubleId
				})
			}
		}
	}
</script>

<style scoped>
	.box {
		min-height: 100vh;
		background-color: #F1F2F5;
	}

	.boxItem {
		padding: 30rpx;
		background-color: #fff;
		box-shadow: 0 2px 4px 0 rgba(237, 237, 237, 0.50);
		border-radius: 16rpx;
		position: relative;
	}

	.name {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #89939E;
		padding-right: 20rpx;
	}

	.value {
		flex: 1;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
	}

	.cob {
		flex: 1;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #3473F9;
	}

	.maintenance {
		background-color: #FFFFFF;
		position: fixed;
		bottom: 0;
		height: 228rpx;
		width: 100%;
		box-shadow: 0 -1px 11px 0 rgba(0, 0, 0, 0.09);
		text-align: center;
		padding: 40rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-around;
	}

	.maintenance image {
		width: 84rpx;
		height: 84rpx;
	}

	.maintenance view {
		font-family: PingFangSC-Regular;
		font-weight: Regular;
		font-size: 28rpx;
		color: #65717D;
	}

	>>>.u-popup__content {
		border-radius: 20rpx;
		overflow: hidden;
	}

	.popup {
		font-size: 32rpx;
		width: 600rpx;
		box-sizing: border-box;
		padding: 60rpx;
	}

	.btn {
		box-sizing: border-box;
		width: 220rpx;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		text-align: center;
		border-radius: 14rpx;
	}

	.but1 {
		border: 1px solid #3473F9;
		color: #3473F9;
	}

	.but2 {
		background-color: #3473F9;
		color: #FFFFFF;
	}
</style>
